package edu.hawaii.duedates.libraries;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.List;
import org.junit.Ignore;
import org.junit.Test;

/**
 * JUnit test cases for the Hawaii State Library's login.
 * 
 * @author Ka Hung Phillip Lau
 * @author Creighton Okada
 *
 */
public class TestHawaiiStateLibrary {
  private final String barcode = System.getProperty("hsl.barcode");
  private final String pin = System.getProperty("hsl.pin");
  HawaiiStateLibrary library = new HawaiiStateLibrary();

  /**
   * Tests loginToHawaiiStateLibraryMethod for correct input with books.
   * Test is run in a configuration from Eclipse IDE using VM Variables.
   * @throws Exception if login is incorrect
   */
  @Ignore
  public void testLoginToHawaiiStateLibrary() throws Exception {
    List<LibraryBook> books = library.getHawaiiStateInfo(this.barcode, this.pin);
    assertEquals("Test if books are borrowed (First character in the table is a '|')",
        '|', books.get(0).getBookTitle().charAt(0));
  }
  /**
   * Tests the output for an account without any books checked out.
   * @throws Exception if login is incorrect
   */
  @Ignore
  public void testNoBooks() throws Exception {
    List<LibraryBook> books = library.getHawaiiStateInfo(this.barcode, this.pin);
    assertTrue("Testing if no books are out.", books.isEmpty());
  }
  /**
   * Tests for illegal login.
   * @throws Exception if login is incorrect
   */
  @Test (expected = Exception.class)
  public void testIllegalLogin() throws Exception {
    library.getHawaiiStateInfo("0000000000", "0000");
    fail("Login shouldn't have passed!"); 
  }
}
